package com.battle.service.controller.web;

import com.battle.pojo.param.log.*;
import com.battle.pojo.vo.log.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
*   web/日志
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@RestController
@RequestMapping("/log/web")
public class LogWebController {

private final LogService service;

public LogWebController(LogService service) {
this.service = service;
}


/**
* 创建日志
* @param param
* @return
*/
@PostMapping("/createLog")
public ApiResult createLog(@RequestBody @Valid CreateLogParam param){
service.createLog(param);
return ApiResult.ok();
}


/**
* 修改日志
* @param param
*/
@PutMapping("/editLog")
public ApiResult editLog(@RequestBody @Valid EditLogParam param){
service.editLog(param);
return ApiResult.ok();
}

/**
* 移除日志
* @param id
*/
@DeleteMapping("/removeLog")
public ApiResult removeLog(@RequestParam("id") Long id){
service.removeLog(id);
return ApiResult.ok();
}

/**
* 启动/禁用日志
* @param id
*/
@GetMapping("/enabledLog")
public ApiResult enabledLog(@RequestParam("id") Long id){
service.enabledLog(id);
return ApiResult.ok();
}

/**
* 获取日志详情
* @param id
* @return
*/
@GetMapping("/getLog")
public ApiResult< GetLogVo> getLog(@RequestParam("id") Long id){
GetLogVo vo = service.getLog(id);
return ApiResult.ok(vo);
}

/**
* 获取日志列表
* @param param
* @return
*/
@PostMapping("/getLogList")
public ApiResult< PageResult< GetLogListVo>> getLogList(@RequestBody GetLogListParam param){
PageResult< GetLogListVo> result = service.getLogList(param);
return ApiResult.ok(result);
}


/**
* 获取日志下拉列表
*
* @return
*/
@PostMapping("/getLogDownList")
public ApiResult< List< GetLogDownListVo > > getLogDownList(@RequestBody(required = false) @Valid GetLogDownListParam param) {
List< GetLogDownListVo > list = service.getLogDownList(param);
return ApiResult.ok(list);
}


}

